@extends('public.layouts')
@section('style')
    <meta name="_token" content="{{ csrf_token() }}"/>
    <style>
    </style>
    <link rel="stylesheet" href="{{asset('admin_assets/css/bootstrap-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="{{url('admin_assets/css/ip.css')}}">
@stop
@section('content')
    <div class="content-wrapper" style="background-color: white">
        <section class="content">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-info"
                         style="padding-top: 0px;margin-top: 0px;border-top: 0px;border-bottom: solid 1px #009aff;">
                        <div class="box-body" style="">
                            <div class="row">
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12" style="margin-top: 1%">
                                    <a href="#" title="返回首页" style="float: left"><i class="fa fa-home fa-2x"
                                                                                    style="width: 100%;color: #009aff">
                                        </i></a>
                                    <a href="#"><span style="font-size: 20px;float: left;color: #009aff">&nbsp;出售已有IP</span></a>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @include('public/alert')
            <div class="row" style="margin-top: 2%">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <form action="{{url('user/ip/doAddOwnIpSell')}}" method="post" enctype="multipart/form-data" style="width: 100%">
                        {{ csrf_field() }}
                        <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <select class="form-control" style="border-radius: 5px" id="first" name="first" onchange="getType($(this));" required>
                                <option value="-1">类型</option>
                                @for($i=0;$i<count($data);$i++)
                                    <option value="{{$data[$i]['id']}}">{{$data[$i]['name']}}</option>
                                @endfor
                            </select>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <select class="form-control" style="border-radius: 5px" id="second" name="second" onchange="getDate($(this))" required>
                                <option value="-1">类别</option>
                            </select>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <select class="form-control" style="border-radius: 5px" id="own_ip" name="own_ip" required>
                                <option value="-1">请选择已有IP</option>
                            </select>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <input type="text" class="form-control" placeholder="期望成交价" id="ideal_price" name="ideal_price" style="border-radius: 5px" required>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <input type="text" class="form-control" placeholder="最低成交价" id="min_price" name="min_price" style="border-radius: 5px" required>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <select class="form-control" style="border-radius: 5px" id="is_authorization" name="is_authorization" required>
                                <option value="-1">是否授权</option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 2%">
                        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 col-lg-offset-4 col-md-offset-4">
                            <button type="submit" class="btn btn-info" style="width: 100%;background: #0080ff">提交</button>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
@stop
@section('javascript')
    <script src="{{asset('admin_assets/js/bootstrap-datetimepicker.min.js')}}"></script>
    <script src="{{asset('js/ip.js')}}"></script>
    <script>
        function getType(e) {
            $.ajax({
                url:'{{url('user/ip/getSecondType')}}',
                type:'post',
                dataType:'json',
                data:{
                    'id': e.val()
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success:function (data) {
                    //console.log(data);
                    var type=$('#second');
                    type.empty();
                    var size=data.length;
                    if (size<=0){
                        type.append('<option value="-1">类别</option>');
                    }else{
                        type.append('<option value="-1">请选择类别</option>');
                        for(var i=0;i<data.length;i++){
                            var item=data[i];
                            type.append('<option value="'+item['id']+'">'+item['name']+'</option>');
                        }
                    }
                }
            })
        }
        function getDate(e) {
            var first=$("#first").val();
            $.ajax({
                url:'{{url('user/ip/getDate')}}',
                type:'post',
                dataType:'json',
                data:{
                    'second': e.val(),
                    'first':first
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success:function (data) {
                    var type=$('#own_ip');
                    type.empty();
                    var size=data.length;
                    if (size<=0){
                        type.append('<option value="-1">请选择已有IP</option>');
                    }else{
                        for(var i=0;i<data.length;i++){
                            var item=data[i];
                            type.append('<option value="'+item['id']+'" >'+item['name']+'</option>');
                        }
                    }
                }
            })
        }
    </script>
@stop
